/* -----------------------------------------------------------------------
 * Using provided template testUpdateCoins.c
 * This tests the great_hall card.
 * -----------------------------------------------------------------------
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

// set NOISY_TEST to 0 to remove printfs from output
#define NOISY_TEST 1

int main() {
    int i, g;
	int num;
    int seed = 1000;
    int numPlayer = 2;
    int maxBonus = 10;
    int p, r, handCount;
    int bonus;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    int maxHandCount = 5;
    // Array of all great_hall cards
	int none[MAX_HAND];
	
    for (i = 0; i < MAX_HAND; i++)
    {
		none[i] = great_hall;
    }

    printf ("TESTING updateCoins():\n");
    p = 0;
    
        for (handCount = 1; handCount <= maxHandCount; handCount++)
        {
            for (bonus = 0; bonus <= maxBonus; bonus++)
            {
#if (NOISY_TEST == 1)
                printf("Test player %d with %d card(s) and %d bonus.\n", p, handCount, bonus);
#endif
                memset(&G, 23, sizeof(struct gameState));   // clear the game state
                r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
				g = handCount; //count before play
				num = G.numActions; //actions before play
                G.handCount[p] = handCount;                 // set the number of cards on hand
				
                memcpy(G.hand[p], none, sizeof(int) * handCount); // set all the cards to great_hall
//baron_card_play (int card, int choice1, int currentPlayer, int cardDrawn, int drawntreasure, struct gameState *state, int handPos, int *bonus)
                 baron_card_play (0, 0, 0, 0, 9, &G, 0, 0, &bonus);
				
		
                
#if (NOISY_TEST == 1)
                printf("handCount = %d, expected = %d\n", G.handCount[p], g ); // original cards - 1 for the great_hall played, + 1 (so just g)
				printf("G.numAction = %d, expected = %d\n", G.numActions, num + 1); // original action + 1 (so just num)

#endif
                assert( G.handCount[p] == g ); // check if the number of cards is correct
				assert( G.numActions == num + 1 ); // check if the number of actions is correct
            }
        }
    

    printf("All tests passed!\n");

    return 0;
}
